Skip to content

Conversation

@radekdoulik
Copy link
Member

Implement return of large valuetypes from reflection calls and also large valuetypes arguments.

Change the order of this and retbuf arguments. This goes toward the #120791 and the new calling convention. It also helps to keep the interpreter calls use simple memory copy.

JIT/Directed/Directed_3 runtime tests were used as repro.

Fixes #122922

@radekdoulik radekdoulik added this to the Future milestone Jan 29, 2026
Copilot AI review requested due to automatic review settings January 29, 2026 15:50
@radekdoulik
Copy link
Member Author

I am also writing down my thoughts on #120791 and will add them soon

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the WASM/CoreCLR interpreter calling convention support so reflection invoke can correctly pass/return large value types (notably SIMD vectors), including adjusting the special-argument ordering (retbuf vs this) and improving stack layout alignment.

Changes:

  • Adjust WASM reflection invoke/call-descriptor plumbing to account for retbuf presence and interpreter stack-slot sizing.
  • Update ArgIterator WASM logic for special-arg offsets and value-type alignment handling.
  • Fix a test failure message to correctly reference Vector128<T>.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tests/JIT/Directed/VectorABI/VectorMgdMgdArray.cs Updates failure message text to reflect Vector128<T> checks.
src/coreclr/vm/wasm/cgencpu.h Refines return-type size macros used by calling convention logic.
src/coreclr/vm/wasm/calldescrworkerwasm.cpp Adjusts interpreter call argument pointer/size handling when a retbuf is present.
src/coreclr/vm/reflectioninvocation.cpp Updates stack-slot counting and records retbuf presence for WASM reflection calls.
src/coreclr/vm/frames.cpp Recomputes this offset via ArgIterator instance (signature-aware).
src/coreclr/vm/callingconvention.h Makes GetThisOffset instance-based; updates WASM special-arg ordering and adds valuetype alignment logic.
src/coreclr/vm/callhelpers.h Adds hasRetBuff field (WASM-only) to CallDescrData.
src/coreclr/vm/callhelpers.cpp Initializes hasRetBuff for WASM call paths and adds a debug assert.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings January 29, 2026 17:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

@radekdoulik radekdoulik requested a review from kg as a code owner January 30, 2026 22:21
Copilot AI review requested due to automatic review settings January 30, 2026 22:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

## Incoming argument ABI

The linear stack pointer `$sp` is the first argument to all methods. At a native->managed transition it is the value of the `$__stack_pointer` global. This global may be updated to the current `$sp` within managed code, and must be up to date with the current `$sp` at managed->native boundaries. Within the method the stack pointer always points at the bottom (lowest address) of the stack; generally this is a fixed offset from the value the stack pointer held on entry, except in methods that can do dynamic allocation.
The linear stack pointer `$sp` is the first argument after the managed `this` argument or the first argument for static methods. At a native->managed transition it is the value of the `$__stack_pointer` global. This global may be updated to the current `$sp` within managed code, and must be up to date with the current `$sp` at managed->native boundaries. Within the method the stack pointer always points at the bottom (lowest address) of the stack; generally this is a fixed offset from the value the stack pointer held on entry, except in methods that can do dynamic allocation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better for stack pointer to be argument 0 so that it is always in a fixed position, and for this to be to after that (if it is present) so that it is in fixed position too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wasm][coreclr] Failing VectorMgdMgdArray_r tests

5 participants